package com.great.dao;

import com.great.domain.Cate;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CateDao {

    @Select("select * from category")//查看所有分类
    public List<Cate> findAllCate();

    @Select("select * from category where cate_parent_id =0")//查看所有父分类
    public List<Cate> findAllParentCate();

    @Insert("insert into category (cate_name,cate_parent_id) values(#{cate_name},#{cate_parent_id})")//添加二级分类
    public void addcate(Cate cate);

    @Select("select * from category where cate_id = #{id}")//查看某一个分类
    public Cate findById(int id);

    @Select("select cate_name from category where cate_id = #{id}")//查看某个分类的名字
    public String findNameById(int id);

    @Update("update category set cate_name=#{cate_name},cate_parent_id=#{cate_parent_id} where cate_id=#{cate_id}")//修改二级分类id
    void updatecate(Cate cate);

    @Delete("delete from category where cate_id=#{id} or cate_parent_id=#{id}")//删除二级分类
    public void delete(int id);
}
